﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EarthGrid.core
{
    public class LonLat
    {
        private int du = 0;
        private int fen = 0;
        private double miao = 0.0;
        private LonLatEnum type;

        /// <summary>
        /// 度，可以没有分
        /// </summary>
        public int Du { get => du; set => du = value; }

        /// <summary>
        /// 分，必须有度的具体有效值，可以没有秒
        /// </summary>
        public int Fen { get => fen; set => fen = value; }

        /// <summary>
        /// 秒，必须有分的具体有效值，可以没有小数
        /// </summary>
        public double Miao { get => miao; set => miao = value; }

        /// <summary>
        /// 是经度还是纬度
        /// </summary>
        public LonLatEnum Type { get => type; set => type = value; }

        public LonLat() { }
        public LonLat(LonLatEnum type, int du, int fen, double miao)
        {
            this.type = type;
            this.du = du;
            this.fen = fen;
            this.miao = miao;
        }

        public double to十进制()
        {
            Double d = du;
            d += (double) fen / 60;
            d += (double) miao / 3600;
            return d;
        }
    }
}
